<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="" method="post">
		<table class="querytable">
			<tr>
				<th class="textright">客户姓名:</th>
				<td class="textleft">
					<input type="text" name="customerName" />
				</td>
				<td class="textleft" id="resultCustomerName"></td>
			</tr>
			<tr>
				<th class="textright">年龄:</th>
				<td class="textleft">
					<input type="text" name="age" />
				</td>
				<td id="resultAge" class="textleft"></td>
			</tr>
			<tr>
				<th class="textright">性别:</th>
				<td class="textleft">
					<input type="radio" name="gender" value="01" />男
					<input type="radio" name="gender" value="02" />女
					
				</td>
				<td class="textleft" id="resultGender"></td>
			</tr>
			<tr>
				<th class="textright">身份证号码:</th>
				<td class="textleft">
					<input type="text" name="IDCard" />
				</td>
				<td id="resultIDCard" class="textleft"></td>
			</tr>
			<tr>
				<th class="textright">客户号码:</th>
				<td class="textleft">
					<input type="text" name="customerNum" />
				</td>
				<td class="textleft" id="resultCustomerNum"></td>
			</tr>
			<tr>
				<th class="textright">地址:</th>
				<td class="textleft">
					<input type="text" name="address" />
				</td>
				<td class="textleft" id="resultAddress"></td>
			</tr>
			<tr>
				<td align="center" colspan="3">
					<input type="button" value="保存用户信息" />
				</td>
			</tr>
		</table>
	</form>
<link rel="stylesheet" href="${pageContext.request.contextPath }/css/editTablestyles.css">
<script type="text/javascript" src="${pageContext.request.contextPath }/webjars/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/listTable.js"></script>
<script type="text/javascript">
	
	$(function() {
		$("input[type='button']").click(function() {
			var customerName=$("input[name='customerName']").val();//姓名
			var age=$("input[name='age']").val();//年龄
			var gender=$("input[name='gender']").val();//性别
			var IDCard=$("input[name='IDCard']").val();//身份证号码
			var customerNum=$("input[name='customerNum']").val();//客户号码
			var address=$("input[name='address']").val();//地址
			if (customerName=="") {
				$("#resultCustomerName").html("请输入客户姓名!");
				return ;
			}
			if (customerName.length<1 || customerName.length>20) {
				$("#resultCustomerName").html("用户名的长度为(英文20位或者中文10位)");
				return ;
			}
			if (age=="") {
				$("#resultAge").html("请输入年龄!");
				return ;
			}
			if (age.length>3) {
				$("#resultAge").html("请输入真实年龄！");
				return ;
			}
			
			if (gender==00) {
				$("#resultGender").html("请选择性别!");
				return ;
			}
			
			
			if (IDCard=="") {
				$("#resultIDCard").html("请输入身份证号码!");
				return ;
			}
			if (IDCard.length!=18) {
				$("#resultIDCard").html("请输入18位的身份证号!");
				return ;
			}
			
			if (customerNum=="") {
				$("#resultCustomerNum").html("请输入客户号码!");
				return ;
			}
			if (customerNum.length<5 || customerNum.length>20) {
				$("#resultCustomerNum").html("请输入6~20位的客户号码!");
				return ;
			}
			
			
			$("form").attr({"action":"customer.action?methodName=doAddCustomer"}).submit();
			return true;
		});
	});
</script>
</body>
</html>